<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of MYSQLConnection
 *
 * @author Fabio
 */
class MYSQLConnection 
{
    public function __construct($params) 
    {
        $params = Setting::getInstance();
        
        $this->DB_HOST_NAME = $params['DB_HOST_NAME'];
        $this->DB_USER_NAME = $params['DB_USER_NAME'];
        $this->DB_PASSWORD = $params['DB_PASSWORD'];
        $this->DB_NAME = $params['DB_NAME'];
    }
    public function openConnection()
    {
        if(!$this->IS_ACTIVE)
        {
            $connection = mysql_connect($this->DB_HOST_NAME, $this->DB_USER_NAME, $this->DB_PASSWORD) or die("DB Connection error");;
        }
        else
        {
            return true;
        }
            
    }
    public function closeConnection()
    {
        if($this->IS_ACTIVE)
        {
            if(mysql_close())
            {
                $this->IS_ACTIVE = false; 
                return true; 
            }
            else
            {
                return false; 
            }
        }
    }
    
    private $IS_ACTIVE;
    private $DB_HOST_NAME;
    private $DB_USER_NAME;
    private $DB_PASSWORD;
    private $DB_NAME;
}

?>
